*1. Import data

import delimited "pausellietal.csv", varnames(1)

*2. Format variables
tab treated
gen treated_dummy=1 if treated=="1"
replace treated_dummy=0 if treated_dummy==.
destring against, replace force
destring ideology_left , replace force
destring v2x_libdem, replace force
gen interaction = china_sup*treated_dummy
egen country_code=group(country_str )
egen title_code=group(title)
gen global_south=0 if country_code ==9 | country_code ==10  | country_code ==15 | country_code ==18| country_code ==21| country_code ==25| country_code ==30| country_code ==32| country_code ==34| country_code ==40| country_code ==43| country_code ==44| country_code ==47| country_code ==50| country_code ==51| country_code ==55| country_code ==56| country_code ==58| country_code ==64| country_code ==67| country_code ==70| country_code ==80| country_code ==85| country_code ==92| country_code ==93| country_code ==94| country_code ==95 | country_code == 101| country_code == 102| country_code == 105| country_code ==106 | country_code == 109 | country_code == 115| country_code == 116| country_code ==117
replace global_south =1 if global_south ==.
gen placebo_treated = treated_dummy
replace placebo_treated =0 if year ==2014
replace placebo_treated =1 if year ==2013
tab placebo_treated
tabstat treated_dummy , by(year)
tabstat treated_dummy placebo_treated  , by(year)
replace treated_dummy  =1 if year ==2008
replace treated_dummy  =1 if year ==2017
replace placebo_treated =1 if year==2008
replace placebo_treated =1 if year==2017
tabstat treated_dummy placebo_treated , by(year)
replace oda=oda/1000000
replace chinese_fdi = chinese_fdi/1000000
gen random=1 if random_resolutions =="Yes"
replace random=0 if random==.
destring treated_india , replace force
gen india_sup=1 if india_support =="Yes"
replace india_sup=0 if india_support =="No"


*3. Install CEM package 
ssc install cem, replace 

* Table A.11: Difference-in-Difference Specification
areg against  china_sup##i.treated_dummy  i.year , absorb(country_code) r
estimates store m1
areg against  china_sup##i.treated_dummy  i.year if country_target_filt =="1" , absorb(country_code) r
estimates store m2

esttab m1 m2, se r2 keep(1.china_sup 1.treated_dummy 1.china_sup#1.treated_dummy)

*Table A.12: Robustness checks through logistic regression with CEM weight
cem title_code country_code, treatment(treated_dummy)
	*Time placebo
logit against  china_sup##i.placebo_treated  oda_cn chinese_fdi agree_china v2x_libdem ideology_left     i.treated_dummy [iweight=cem_weights] , vce(cluster year) or
estimates store m2
	*Placebo China
logit against  china_sup##i.treated_dummy oda_cn chinese_fdi agree_china ideology_left v2x_libdem i.treated_dummy [iweight=cem_weights] if random ==1, vce(cluster year)
estimates store m3
	*India
logit against c.treated_india##c.india_sup oda_cn chinese_fdi agree_china ideology_left v2x_libdem i.treated_dummy [iweight=cem_weights], vce(cluster year) or
estimates store m4

esttab m2 m3 m4, se eform